package com.lq.ecoldchain.ui.mymileage

import android.support.v4.app.Fragment
import com.lq.ecoldchain.ui.mymileage.details.MileageDetailFragment
import com.lq.ecoldchain.ui.mymileage.ranking.MileageRankingFragment
import org.kodein.di.Kodein
import org.kodein.di.android.ActivityRetainedScope
import org.kodein.di.android.support.AndroidLifecycleScope
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.scoped
import org.kodein.di.generic.singleton

/*
*2019/1/6 0006  14:17
*function by lq
*/
val mileageKodeinModule = Kodein.Module("Mileage_Kodein_Module") {

    bind<MileageDetailFragment>() with scoped(AndroidLifecycleScope).singleton {
        MileageDetailFragment()
    }

    bind<MileageRankingFragment>() with scoped(AndroidLifecycleScope).singleton {
        MileageRankingFragment()
    }

    bind<MileageViewModel>() with scoped(AndroidLifecycleScope).singleton {
        MileageViewModel()
    }

    bind<List<Fragment>>() with scoped(ActivityRetainedScope).singleton {
        listOf(instance<MileageDetailFragment>(),instance<MileageRankingFragment>())
    }

    bind<MileageDelegate>() with scoped(AndroidLifecycleScope).singleton {
        MileageDelegate(
                manager = instance(),
                fragments = instance(),
                viewModel = instance()
        )
    }
}
